import random

import requests

# request_urls = set()
#
# urls = [f'https://httpbin.org/get?age={random.randint(1, 10)}' for i in range(10)]
#
# for url in urls:
#     if url not in request_urls:
#         request_urls.add(url)
#         response = requests.get(url)
#         print(response.json())
#     else:
#         print("该请求已经请求过")


import hashlib
import json

url = 'https://httpbin.org/post'

datas = [{'id':1, 'value':random.randint(1, 10)} for i in range(10)]

request_post_datas = set()

for data in datas:
    request_post_data = hashlib.md5(json.dumps(data).encode('utf-8')).hexdigest()
    if request_post_data not in request_post_datas:
        request_post_datas.add(request_post_data)
        response = requests.post(url, data=data)
        print(response.json())
    else:
        print("post请求重复")